package com.spring.springtest.controller;

import com.spring.springtest.domain.user;
import com.spring.springtest.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/users")
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/get-allusers")
    public List<user> getAllUsers() {
        return userService.getAllUsers();
    }
    @GetMapping("/get")
    public user getUserById() {
        int id = 1;
        System.out.println(userService.findUserById(id).toString());
        return userService.findUserById(id);
    }
}
